package com.sikadwafastdaisfondturbo.pretloan.utils.http

import com.sikadwa.analysis.AnalyticsUtil
import com.sikadwafastdaisfondturbo.pretloan.BuildConfig
import com.sikadwafastdaisfondturbo.pretloan.utils.config.Configs
import org.json.JSONObject
import java.util.Locale

/**
 * Sikadwa
 * @Author wwdeng
 * @CreateTime: 2024/5/21 15:19
 * @Annotation： 接口地址
 */
object AppUrls {

    /**
     * https://www.maxpas-info.online
     * http://159.138.165.72
     */
    var APP_URL = "https://www.maxpas-info.online"

    object URL {
        /**
         * 地区转发
         */
        const val TIMEZONE = "/bdyqhloilpqpm0yjvt0fmq"
        /**
         * APP业务统一请求接口
         */
        const val COMMON = "/yQ4tnes08gUZz7zBwXLFw"
        /**
         * 文件上传
         */
        const val FILE = "/lHscrlySwQueY4SwcgxLpw"
    }

    object PATH {
        /**
         * APP配置参数 Path
         * /v1/getAppShowInfo
         */
        const val APP_INFO = "XRTFULokOaMOcKtxdUNqA"

        /**
         * 发送验证码
         * /v1/smsCode
         */
        const val SEND_SMS = "g0IIYRo42aJXVkjJE4AA"

        /**
         * 发送whatsapp验证码
         * /v1/sendWhatAppMessage
         */
        const val WHATSAPP_SEND_CODE_PATH = "bWb3b7lEe85WimFBsNqyBg"

        /**
         * 校验whatsapp验证码
         *  /v1/checkWhatAppMessageCode
         */
        const val WHATSAPP_CHECK_CODE_PATH = "WIYtggG7Jf11Ev8UgN5R1g"

        /**
         * 登录
         * /v1/userLogin
         */
        const val LOGIN = "EdiemgC9eVP0S69qoXHg"

        /**
         * 无验证码登录
         * /v1/userLoginNoCode
         */
        const val LOGIN_NO_CODE = "b0ok8NK6r6IzyfxAMcT4nQ"

        /**
         * 用户流程状态
         * /v1/userProcess
         */
        const val PROCESS = "l3THLdYRbNwih5YlbjzrJw"
        /**
         * 保存用户图片信息（身份证、护照、驾驶证、人脸）
         * /v1/ocrInfo
         */
        const val OCR_INFO = "mwTlpvv6KcDzxEQ97tt2BA"

        /**
         * 用户贷款额度
         * /v1/loanLimit
         */
        const val LIMIT = "LPevjEqpe3OaYWFAl6wFTA"

        /**
         * 新用户贷款额度预览信息
         * /v1/getLoanApplyDetail
         */
        const val CREDIT_APPLY = "ajf4D2XNH47dk7kU5vgEw"

        /**
         * 可选额度和期限的预览信息(老用户)
         * /getLoanDetailPageForDays
         */
        const val CREDIT_APPLY_CUSTOM_LIMIT = "ajf3D5NWH47af7kU5vgEw"

        /**
         * 创建贷款申请订单
         * /v1/loanApply
         */
        const val CREDIT_APPLY_ORDER_CREATE = "g9Y1Vc2ukf7KmurKJzWtBNw"

        /**
         * 贷款还款信息
         * /v1/repayInfo
         */
        const val CREDIT_REPAYMENT_INFO = "zyVZWmS4wC5ak0SZC9Er3A"
        /**
         * 贷款还款信息
         * /v1/getOrderRepayH5
         */
        const val CREDIT_REPAYMENT_URL = "g2S3xbzzxkaF9nzlwXFKPJw"

        /**
         * 账户列表
         * /v1/getBindCardList
         */
        const val ACCOUNT_LIST = "ElXxwgiqkvs3VEKuFYx6A"
        /**
         * 已绑定账户列表（法语）
         * /v2/fetchBoundBankAccount
         */
        const val ACCOUNT_LIST_FRENCH = "dvecd8ib594QJAv4OpZQ"
        /**
         * 添加账户
         * /v2/bindBankAccount
         */
        const val ACCOUNT_ADD = "TpENm8XZ95XEIeFuPkRQ"
        /**
         * 删除已绑定的账户
         * /v1/deleteBoundBankAccount
         */
        const val ACCOUNT_DELETE = "YbVBsciLlV2hYd037QmZvQ"
        /**
         * 评价弹框
         * /v1/fetchStarWindowConfig
         */
        const val STAR_COMMENT = "Ct1oZQlPrE7HO4CnqZc7A"

        /**
         * 提交意见反馈
         * /v1/feedback
         */
        const val FEEDBACK_SUBMIT = "cmIxqwnP9k5PYJZeXQxgjg"

        /**
         * 推荐APP列表
         * /v1/userDeniedDc
         */
        const val RECOMMEND_APP_LIST = "zZShPZ14fpnmIYLGpeG6A"
        /**
         * 事件埋点
         * /v1/userBuriedPoint
         */
        const val TRACK_EVENT = "oAE8u9vXC10Bv26WpVVumQ"
        /**
         * 事件批量埋点
         * v1/userBuriedPointForBatch
         */
        const val TRACK_EVENT_BATCH = "h5BondYzWxPp3MSC62ySSw"

        /**
         * 清除用户数据(新)
         * /v1/dropUserData
         */
        const val USER_DATA_CLEAR = "DdxeJbSXPAN7K8xY8de8xg"

        /**
         * 产品额度是否有提升
         * /v1/amountIsUp
         */
        const val LIMIT_INCREASED_PATH = "sGLMHk33HWl3y4lQ3WafwQ"

        /**
         * 设备数据上传状态
         * /v1/queryDeviceInfoTypes
         */
        const val DEVICE_INFO_TYPES = "BjggmAUNqW3XUSSVXxDu0Q"
    }

    /**
     * 获取请求Url
     */
    fun getHttpUrl(url: String): String{
        //地区转发
        val timeZone = Configs.getSPString(Configs.SPKEY.SIKADWA_TIMEZONE)
        if (timeZone.isNotEmpty()){
            return "$APP_URL/$timeZone$url"
        }
        return "$APP_URL$url"
    }

    fun JSONObject.addCommonParams(): JSONObject {
        apply {
            put("product", Configs.AppName)                                                   //  产品 APP名称
            put("token", Configs.getSPString(Configs.SPKEY.SIKADWA_TOKEN))                    //  token
            put("apiVersion","v3")                                                      //  接口版本
            put("androidId", AnalyticsUtil.getAndroidId())                                    //  安卓id
            put("advertId", AnalyticsUtil.getAdId())                                          //  广告id
            put("aduid", AnalyticsUtil.getAdId())                                             //  广告id
            put("aduidPath", AnalyticsUtil.getAndroidId())                                    //  广告地址
            put("isLimitAdTrackingEnabled", AnalyticsUtil.getAdEnabled().toString())          //  是否限制广告id，1是 0否
            put("userId", Configs.getSPString(Configs.SPKEY.SIKADWA_USERID))                  //  userId
            put("version", BuildConfig.VERSION_CODE)                                          //  app版本号
            put("timp",System.currentTimeMillis())                                            //  时间戳
            put("country", Configs.getSPString(Configs.SPKEY.SIKADWA_TIMEZONE_COUNTRY))       //  国家标识
            put("tzid", Configs.getSPString(Configs.SPKEY.SIKADWA_TIMEZONE_ID))               //  当前时区id
            put("localTimestamp","${System.currentTimeMillis()}")                       //时间戳
            put("lang", Locale.getDefault().language)                                         //当前语言
//            put("path","")                                                                         //  传映射后的接口路径，不带前面的/号
        }
        return this
    }

}